// pages/storesearch/storesearch.js

var amapFile = require('../../libs/amap-wx.js');
let amap = require("../../libs/amap.js");

var myAmapFun = new amapFile.AMapWX({

  key: '1336bfc7fd9f11ec452d1d4f0cab4c8c' // 必填 换成自己申请到的

});

Page({

  /**
   * 页面的初始数据
   */
  data: {
    haveResult:false,
    tips:[],
    lonlat: "",
    city: "",
    select_index:0,
    tabItems:[{
      id:1,
      name:'美食'
    },{
     id:2,
     name:'景区'
    },{
      id: 3,
      name: '酒店'
    },{
      id:4,
      name:'超市'
    },{
      id:5,
      name:'娱乐场所'
    }]
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    console.log(options)

    let { lonlat, city } = options;
    this.setData({
      lonlat, city
    })
  },
  clickItem:function(e){
    console.log(e.currentTarget.dataset.index,'clickItem');

    this.setData({
      select_index: e.currentTarget.dataset.index
    })
  },
  bindInput:function(e){
    var that = this;
    var keywords = e.detail.value;

    let { value } = e.detail;
    let { lonlat, city } = this.data;

    
    myAmapFun.getInputtips({
      keywords: keywords,
      location: lonlat,
      success: function (data) {
        console.log(data);
        if (data && data.tips) {
          that.setData({
            tips: data.tips,
            haveResult:true
          });
        }

      }
    })
 
  },
  bindSearch:function(e){
    var keywords = e.target.dataset.keywords;

  },
  goThere:function(e){
    //传递location 方便定位
    wx.navigateTo({
      url: '../tenantsdetail/tenantsdetail',
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
  
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
  
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
  
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
  
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
  
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
  
  }
})

// https://blog.csdn.net/h330531987/article/details/80651139